﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace VNWIKI_WEB.DAO
{
    public class AdminDAO
    {
        public int InsertPhoto(Album album, string photoName, string link)
        {
            int rs = 0;
            VNWIKIDataContext dt = new VNWIKIDataContext();

            try
            {
                Photo photo = new Photo();
                photo.AlbumID = album.ID;
                photo.Name = photoName;
                photo.Link = link;
                photo.Views = 0;
                photo.CreateDate = String.Format("{0:dd/MM/yyyy HH:mm:ss tt}", DateTime.Now);
                photo.Deleted = false;
                dt.Photos.InsertOnSubmit(photo);
                dt.SubmitChanges();
                rs = 1;
            }
            catch { rs = 0; }
            return rs;
        }

        public int InsertAlbum(string albumName, string tags, int catID, int userID)
        {
            int rs = 0;
            VNWIKIDataContext dt = new VNWIKIDataContext();
            try
            {
                Album album = new Album();
                album.CategoryID = catID;
                album.Name = albumName;
                album.Tags = tags;
                album.Views = 0;
                album.Vote = 0;
                album.UserID = userID;
                album.CreateDate = String.Format("{0:dd/MM/yyyy HH:mm:ss tt}", DateTime.Now);
                album.Deleted = false;
                dt.Albums.InsertOnSubmit(album);
                dt.SubmitChanges();
                rs = 1;
            }
            catch { rs = 0; }
            return rs;
        }
    }
}